<template>
  <div>
    <div style="padding: 5px 10px">
      <h3>办理情况:</h3>
      <process-handle-history :business-key="businessKey" :process-key="processKey"/>
    </div>
    <div style="padding: 5px 10px">
      <h3>编制要求:<p style="font-weight: 400;padding: 0 60px">{{requirement}}</p></h3>
      <div v-if="!requirement||requirement==''"
           style="text-align: center;font-size: 18px;color: #3333;height: 130px;line-height: 130px;">
        暂无数据
      </div>
    </div>
    <div style="padding: 5px 10px">
      <h3>会商信息:</h3>
      <topic-detail :topic-list="detaildata.topicDetail"></topic-detail>
    </div>
    <assign-history :visible="assignHisVisible"
                    :taskAssigneeHisList="taskAssigneeHisList"
                    @cancelAssignHis="cancelAssignHis"></assign-history>
  </div>
</template>

<script>
  import {getRegisterDetail} from "@/api/achievement";
  import topicDetail from "@/components/topic/detail.vue";
  import {getAchievementDetail} from "@/api/achievement";
  import {getRegisterinfo} from "@/api/registerinfo/registerinfo";
  import processHandleHistory from "@/components/activiti/history/processHandleHistory";

  export default {
    name: "registerinfoDetailPage",
    components: {
      getRegisterDetail,
      topicDetail,
      processHandleHistory
    },
    data() {
      return {
        detaildata: {},
        requirement: null,
        assignHisVisible: false,
        taskAssigneeHisList: [],
        businessKey: null,
        processKey: 'planning-register'
      }
    },
    props: {
      id: Number,
    },
    created() {
      this.getRegisterDetailData();
      this.getAchievementDetailData();
    },
    computed: {},
    methods: {
      getRegisterDetailData() {
        getRegisterDetail(this.id).then(response => {
          if (response.data.code == 0) {
            if(response.data.data!=null){
              this.detaildata = response.data.data;
            }
          }
        });
      },
      getAchievementDetailData() {
        getAchievementDetail(this.id).then(async response => {
          if (response.data.code == 0) {
            let registerinfoIdTemp = await response.data.data.registerinfoId;
            this.businessKey = registerinfoIdTemp;
            this.getRegisterinfoDetail(registerinfoIdTemp);
          }
        });
      },
      getRegisterinfoDetail(registerinfoId) {
        if (registerinfoId != null) {
          getRegisterinfo(registerinfoId).then(response => {
            this.requirement = response.data.data.requirement;
          })
        }
      },
      taskAssigneeHisView(taskAssigneeHisList) {
        this.assignHisVisible = true;
        this.taskAssigneeHisList = taskAssigneeHisList
      },
      cancelAssignHis() {
        this.assignHisVisible = false;
      }
    }
  }
</script>
